<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@include file="common/header.jsp"%>
        <!-- /. NAV SIDE  -->
<div id="page-wrapper">
	<div id="page-inner">

		<div class="row">
			<div class="col-md-12">
				<!-- Advanced Tables -->
				<div class="panel panel-default">
					<div class="panel-heading">订单记录表</div>


					<div class="panel-body">
						<div class="table-responsive">
							<table class="table table-striped table-bordered table-hover">
								<thead>
									<tr>
										<th>订单编号</th>
										<th>订单编码</th>
										<th>商品名称</th>
										<th>用户编码</th>
										<th>创建日期</th>
										<th>使用日期</th>
										<th>订单状态</th>
										<th>支付状态</th>
										<th>操作</th>
									</tr>
								</thead>
								<tbody>
									<c:forEach var="bill" items="${list}" >

										<tr>
											<td><span>${bill.b_id }</span></td>
											<td><span>${bill.b_Code }</span></td>
											<td><span>${bill.p_Name}</span></td>
											<td><span>${bill.userCode}</span></td>
											<td><span><fmt:formatDate
														value='${bill.createDate }' pattern="yyyy-MM-dd" /> </span></td>
											<td><span><fmt:formatDate
														value='${bill.usingDate }' pattern="yyyy-MM-dd" /> </span></td>
											<td><c:if test="${bill.status==0 }"><span>未处理</span></c:if>
												<c:if test="${bill.status==1 }"><span>已处理</span></c:if>
											 </td>
										
											<td><c:if test="${bill.isPay==1}">
													<span>已支付</span>
												</c:if> <c:if test="${bill.isPay==0}">
													<span>未支付</span>
												</c:if></td>
												
												 <td><span><%-- <a title="查看"
													href="${pageContext.request.contextPath }/provider/${provider.id }/view"><i class="glyphicon glyphicon-eye-open"></i></a></span> --%>
												<span ><a title="处理订单"  class="modify"
													href="javascript:;" b_id=${bill.b_id } status=${bill.status }><i class="glyphicon glyphicon-edit"></i></a></span>
												<span ><a class="deleteBill" href="javascript:;" title="删除订单"
													b_id=${bill.b_id } b_Code=${bill.b_Code } ><i class="glyphicon glyphicon-trash"></i> </a></span></td>
											<td><span>${provider.productType}</span></td> 
										</tr>

									</c:forEach>
								</tbody>
							</table>
							<input type="hidden" id="totalPageCount"
								value="${totalPageCount}" />

							<div class="row">
								<div class="col-md-6 col-md-push-3">
									<div class="dataTables_info" id="dataTables-example_info"
										role="alert" aria-live="polite" aria-relevant="all">共${totalCount }条记录&nbsp;&nbsp;
										${currentPageNo }/${totalPageCount }页</div>
								</div>
								<div class="col-md-4">
									<div class="dataTables_info" id="dataTables-example_paginate">

										<c:if test="${currentPageNo > 1}">
											<a href="${pageContext.request.contextPath }/provider/billList?proCode=${providerSession.proCode}&pageIndex=1">首页</a>
											<a	href="${pageContext.request.contextPath }/provider/billList?proCode=${providerSession.proCode}&pageIndex=${currentPageNo-1}" >上一页</a>
										</c:if>
										<c:if test="${currentPageNo < totalPageCount }">
											<a
												href="${pageContext.request.contextPath }/provider/billList?proCode=${providerSession.proCode}&pageIndex=${currentPageNo+1}" ">下一页</a>
											<a
												href="${pageContext.request.contextPath }/provider/billList?proCode=${providerSession.proCode}&pageIndex=${totalPageCount }">最后一页</a>
										</c:if>

									</div>
								</div>
							</div>


						</div>

					</div>
				</div>
				<!--End Advanced Tables -->
			</div>
		</div>



		<footer>

		</footer>
	</div>
	<!-- /. PAGE INNER  -->
</div>
<!-- /. PAGE WRAPPER  -->
<!-- /. WRAPPER  -->


<!-- JS Scripts-->
    <!-- jQuery Js -->
    <%@include file="common/js.jsp"%>
    <script type="text/javascript" src="${pageContext.request.contextPath }/statics/js/rollpage.js"></script>
    <script>
    
    $(".modify").on('click',function(){
    var obj = $(this);
    var status = obj.attr("status");
    var modifyId = obj.attr("b_id");
    if(status==1){
    alert("此订单已处理");
    }else{
    $.ajax({
				url : "/Trip/provider/billmodify",
				data: {b_id:modifyId},
				dataType:"json",
				success : function(data){
					if(data.result=="true"){
					alert("成功处理！");
					window.location.reload();
					}else if(data.result=="false"){
					alert("处理失败");
					}
				}
			});
    
    }
    })
    
    
          $(".deleteBill").click(function(){
		var obj = $(this);
		var deleteId = obj.attr("b_id");
		
		 if(confirm("确定要删除订单【"+obj.attr("b_Code")+"】吗？")){ 
			$.ajax({
				url : "/Trip/provider/billdelete",
				data: {b_id:deleteId},
				dataType:"json",
				success : function(data){
					if(data.delResult=="true"){
					alert("删除成功！");
					window.location.reload();
					}else if(data.delResult=="false"){
					alert("删除失败");
					}else{
					alert(data.delResult);
					}
				}
			});
			
		}
	});
	
	
	
    </script>
    
   
</body>
</html>
